package com.flymobi.service;

import java.util.List;

import com.flymobi.fw.modules.CommonService;
import com.flymobi.fw.modules.SM;
import com.flymobi.fw.modules.cache.CacheNeedsRefreshException;
import com.flymobi.po.Qudao;
import com.flymobi.util.QL;

public class QudaoService extends CommonService {

	public List<Qudao> list(int startRow, int pagePerSize) {
		return dao.find(Qudao.class, QL.HQL.Qudao.LIST, new Object[] {},
				startRow, pagePerSize);
	}

	public Long getCount() {
		return dao.getCount(QL.HQL.Qudao.GET_COUNT, new Object[] {});
	}

	public void save(Qudao Qudao) {
		dao.save(Qudao);
	}

	public Qudao load(String id) {
		return dao.load(Qudao.class, new Long(id));
	}

	public Qudao get(String id) {
		return dao.get(Qudao.class, new Long(id));
	}

	public void delete(String id) {
		dao.delete(this.get(id));
	}

	public Qudao getFromCache(String code) {
		Qudao qudao=null;
		try {
			qudao = (Qudao)SM.CacheOscache.getFromCache("qudao", code, 30*60);
		} catch (CacheNeedsRefreshException e) {
			qudao=dao.findSingle(Qudao.class, QL.HQL.Qudao.find_by_code,
					new Object[] { code });
			SM.CacheOscache.putInCache("qudao", code, qudao);
		}
		return qudao;
	}
}
